package com.zky.handler;

import com.zky.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestControllerAdvice
@Slf4j
public class globalExceptionHandler {
    @ExceptionHandler
    public Result exceptionHandler(Exception e, HttpServletRequest request, HttpServletResponse response) {
        response.setStatus(500);
        return Result.fail(e.getMessage());
    }
}
